﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using WhereIsMyCash.Enums;

namespace WhereIsMyCash.IDAL
{
    /// <summary>
    /// 一般性数据操作接口，实现一般的CRUD功能
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public interface ICRUD<T>
    {
        /// <summary>
        /// 检测实体是否已经存在
        /// </summary>
        /// <param name="entity">实体</param>
        /// <param name="checkType">检测类型枚举</param>
        /// <returns></returns>
        bool IsExist(T entity, EnumExsistingCheckType checkType);

        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="entity">实体</param>
        /// <returns></returns>
        int Add(T entity);

        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="entity">实体</param>
        void Update(T entity);

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="ID">实体ID</param>
        void Delete(int Id);

        /// <summary>
        /// 返回实体
        /// </summary>
        /// <param name="Id">实体ID</param>
        /// <returns></returns>
        T GetInfo(int Id);

        /// <summary>
        /// 返回实体列表
        /// </summary>
        /// <param name="condition">条件</param>
        /// <returns></returns>
        List<T> GetList(string condition);

        /// <summary>
        /// 返回实体列表
        /// </summary>
        /// <param name="pageSize">分页大小</param>
        /// <param name="curPage">当前页码</param>
        /// <param name="condition">查询条件</param>
        /// <returns></returns>
        List<T> GetList(int pageSize, int curPage, string condition);

        /// <summary>
        /// 返回数量
        /// </summary>
        /// <param name="condition"></param>
        /// <returns></returns>
        int GetCount(string condition);
    }
}
